/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Linker;

import Common.ObjectFileRecord;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Kyle
 */
public class LoaderFile
{

    public List<ObjectFileRecord> Records;
    public ObjectFileRecord HRecord;
    public ObjectFileRecord ERecord;
    int NumTRecords;
    int NumRecords;

    public LoaderFile()
    {
        Records = new ArrayList<ObjectFileRecord>();
        NumTRecords = 0;
        NumRecords = 0;
    }

    public void AddRecord(String type, ObjectFileRecord record)
    {
        NumRecords++;
        if (type.equals("T"))
        {
            NumTRecords++;
            Records.add(record);
        }
        else if (type.equals("H"))
        {
            HRecord = record;
        }
        else if (type.equals("E"))
        {
            ERecord = record;
        }
        record.Type = type;

    }

    public void PrintToFile(PrintStream out)
    {
        HRecord.PrintRecord(out);
        for(ObjectFileRecord r : Records)
        {
            r.PrintRecord(out);
        }
        ERecord.PrintRecord(out);
    }

}
